package cn.itcast.web.action;

import cn.itcast.domain.base.TakeTime;
import cn.itcast.service.TakeTimeService;
import cn.itcast.utils.ResponseUtils;
import cn.itcast.web.action.common.BaseAction;
import com.alibaba.fastjson.JSONArray;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.util.List;


@Namespace("/")
@ParentPackage("struts-default")
@Controller
@Scope("prototype")
public class TakeTimeAction extends BaseAction<TakeTime> {
    @Autowired
    private TakeTimeService takeTimeService;

    //"url:'../../taketime_findAll.action',关联收派时间下拉项
    @Action(value = "taketime_findAll")
    public String findAll(){
        List<TakeTime>takeTimes= takeTimeService.findAll();
        String json=JSONArray.toJSONString(takeTimes);
        ResponseUtils.responseWriter(json);
        return NONE;
    }
}
